#include "stdafx.h"

#include "StickyTweetsXP.h"

#include "SearchEdit.h"

LRESULT CALLBACK SearchEdit(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR pSubClassId, DWORD_PTR pReferenceData)
{
  switch (message)
  {
  case WM_CHAR:
    switch (wParam)
    {
    case VK_RETURN:
      Search();
      return 0;

    case VK_TAB:
    case VK_ESCAPE:
      SendMessage(hWndStickyTweets, message, wParam, lParam);
      return 0;
    }
    break;

  case WM_KEYDOWN:
    switch (wParam)
    {
    case VK_HOME:
    case VK_END:
      if (GetWindowTextLength(hWnd) > 0)
        return DefSubclassProc(hWnd, message, wParam, lParam);
      else
        SendMessage(hWndStickyTweets, message, wParam, lParam);
      break;

    case VK_UP:
    case VK_DOWN:
    case VK_PRIOR:
    case VK_NEXT:
    case VK_F5:
      SendMessage(hWndStickyTweets, message, wParam, lParam);
      return 0;
    }
    break;
  }
  return DefSubclassProc(hWnd, message, wParam, lParam);
}
